package com.ruoyi.assets.queue.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class MessageProducer {

    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 将消息推送到队列
     *
     * @param queueName 队列名称
     * @param message   消息内容
     */
    public <T> void sendMessage(String queueName, T message) {
        redisTemplate.opsForList().leftPush(queueName, message);
        System.out.println("消息已发送: " + message);
    }
}